package com.atguigu.yygh.msm.controller;/*
 * @author: XueYouPeng
 * @time: 2023/6/13 18:29
 */

import com.atguigu.common.result.Result;
import com.atguigu.yygh.msm.service.MsmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/msm")
public class MsmController {

    @Autowired
    MsmService msmService;

    /**
     * 给手机号发送短信验证码
     * 判断是否存在有限期内的验证码；如果不存在调用第三方短信接口；发送成功后，存入到redis，phone作为k，code作为v，存储时间5分钟
     * @param phone
     * @return
     */
    @GetMapping("sendCode/{phone}")
    public Result sendCode(@PathVariable String phone){
        msmService.sendCode(phone);
        return Result.ok();
    }
}
